<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    template="/template.xhtml"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core">
    
    <ui:define name="title"></ui:define>
    <ui:define name="content">
     <!--   <c:if test="#{userBean.currentUser.role == 'ADMIN'}"> -->
        
        <div id="adminmenu">
              <ui:include src="./menu.xhtml"></ui:include> 
        </div>
        <h3>Управление меню ресторана</h3>
        <div id="dataM">
        <div class="dataExport">
            <h:form>  
            <h:panelGrid columns="2">  
                <p:panel header="Експортировать все данные">  
                    <h:commandLink>  
                        <p:graphicImage value="/img/xls.png" />  
                        <p:dataExporter type="xls" target=":productsList:allProducts" fileName="allProducts" />  
                    </h:commandLink>  

                    <h:commandLink>  
                        <p:graphicImage value="/img/file_pdf.png" />  
                        <p:dataExporter type="pdf" target=":productsList:allProducts" fileName="allProducts"/>  
                    </h:commandLink>  

                    <h:commandLink>  
                        <p:graphicImage value="/img/csv_text.png" />  
                        <p:dataExporter type="csv" target=":productsList:allProducts" fileName="allProducts" />  
                    </h:commandLink>  

                    <h:commandLink>  
                        <p:graphicImage value="/img/file_xml.png" />  
                        <p:dataExporter type="xml" target=":productsList:allProducts" fileName="allProducts" />  
                    </h:commandLink>  
                </p:panel>  

                
            </h:panelGrid>    
           </h:form>
         </div>
            
        <div class="btnRight">
            <p:commandButton id="basic" value="Добавить новое блюдо" onclick="dlg.show();" type="button" />
            <p:dialog header="Создание нового блдюда" widgetVar="dlg" maximizable="true" minimizable="true">  
            <h:form prependId="false">
                <h:panelGrid columns="2" columnClasses="column" cellpadding="5"> 
                    <h:outputText value="Название блюда"/> 
                    <p:inputText value="#{productsBean.newProducts.name}"/>
                    
                    
                    <h:outputText value="Тип блюда"/> 
                    <h:selectOneMenu value="#{productsBean.newProducts.typeProducts}">
                        <f:selectItems value="#{productsBean.typeProducts}"
                                                   var="type3"
                                                   itemLabel="#{type3}"
                                                   itemValue="#{type3}"
                                                   >
                                    </f:selectItems>
                                </h:selectOneMenu>
                    <h:outputText value="Цена"/>
                    <p:inputText value="#{productsBean.newProducts.price}"/>
                    <h:outputText value="Цена за"/>
                    <p:inputTextarea value="#{productsBean.newProducts.typePrice}"/>
                    <h:outputText value="Информация"/> 
                    <p:inputTextarea value="#{productsBean.newProducts.info}"/>
                </h:panelGrid>

                <h:commandButton class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" value="Создать"   actionListener="#{productsBean.saveProducts}"/>
            </h:form>
        </p:dialog>  
        </div>
       </div>
         <h:form id="productsList" >
 
            <p:contextMenu for="allProducts">
                <p:menuitem value="Просмотреть" update=":d" icon="ui-icon-search" oncomplete="productsDislay.show()"/>
                <p:menuitem value="Удалить" update="allProducts" icon="ui-icon-close" actionListener="#{productsBean.deleteProducts}"/>
                
            </p:contextMenu>
            
            <p:growl id="messages" showDetail="true"/>
            <p:dataTable paginator="true" rows="15" var="products" value="#{productsBean.allProducts}"  id="allProducts" rowKey="#{products.name}" 
                         selection="#{productsBean.selectProducts}" selectionMode="single"
                         >
                  
                   
                <p:column headerText="Название блюда" sortBy="#{products.name}" filterBy="#{products.name}" style="width: 5%">
                    <h:outputText value="#{products.name}"/>
                </p:column>
                    
                <p:column headerText="Тип блюда"  sortBy="#{products.typeProducts}" filterBy="#{products.typeProducts}" style="width: 5%">
                    <h:outputText value="#{products.typeProducts}"/>
                </p:column>
                <p:column headerText="Цена (грн.)"  style="width: 5%">
                    <h:outputText value="#{products.price}"/>
                </p:column>    

             </p:dataTable>  
               
                
                
             
            
            
        </h:form>
        
        <p:dialog header="Подробная информация " widgetVar="productsDislay" resizable="false"
                             width="600" showEffect="clips" hideEffect="fold" id="d1">
                       <h:panelGrid id="d" columns="2">
                           <h:outputText value="Название блюда:" /> 
                           <h:outputText id="pebd" value="#{productsBean.selectProducts.name}" />
                            <h:outputText value="Тип блюда:" /> 
                            <h:outputText value="#{productsBean.selectProducts.typeProducts}" />
                             <h:outputText value="Цена:" /> 
                             <h:outputText value="#{productsBean.selectProducts.price} грн." />
                              <h:outputText value="Цена за:" /> 
                              <h:outputText value="#{productsBean.selectProducts.typePrice}" />
                               <h:outputText value="Информация:" /> 
                               <h:outputText value="#{productsBean.selectProducts.info} " />
                       </h:panelGrid>
             <p:commandButton value="Print" type="button" icon="ui-icon-print">  
                             <p:printer target="d" />  
                        </p:commandButton>  
                   </p:dialog>
        
      
       <!-- </c:if> -->
    </ui:define>
</ui:composition>
